import React from 'react'

export default function ProductsUi(props) {
  return (
    <ul>
      {
        props.products.map(p => {
          return (
            <li key={p.id}>
              {p.name} - ￥{p.price}
              <button 
                onClick={() => props.addToCart(p)}
                disabled={p.inventory <= 0}
              >
                放入购物车
              </button>
            </li>
          )
        })
      }
    </ul>
  )
}
